<!DOCTYPE html>
<html>

	<head>
		<link rel="icon" href="img/bitbug_favicon.ico" type="image/x-icon" />
		<meta charset="UTF-8">
		<title>渠道拓展CRM管理系统</title>
		<link rel="stylesheet" type="text/css" href="layui/css/layui.css" />
		<link rel="stylesheet" type="text/css" href="css/Myuser.css" />
		<link rel="stylesheet" type="text/css" href="css/_reset.css" />
		<link rel="stylesheet" type="text/css" href="css/common.css" />
	</head>

	<body style="overflow-x: hidden;overflow-y: auto;">
		<!--导航栏-->
		<div class="header commons_son commons">
			<div class="header_son">
				<ul class="layui-nav layui-bg-cyan">
					<li class="layui-nav-item">
						<a><img src="img/logo.png" />渠道拓展CRM</a>
					</li>
					<li class="layui-nav-item index_header hide" id="ziyuan" data-type="ziyuan_type">
						<a href="#index">资源线索</a>
					</li>
					<li class="layui-nav-item MyUser_header hide" id="kehu" data-type="kehu_type">
						<a href="#Myuser">我的客户</a>
					</li>
					<li class="layui-nav-item Service_header hide" id="shuju" data-type="shuju_type">
						<a href="#Service">数据客服中心</a>
					</li>
					<li class="layui-nav-item Oganization_header hide" id="zuzhi" data-type="zuzhi_type">
						<a href="#Oganization">组织架构</a>
					</li>
					<li class="layui-nav-item Statistical_header hide" id="tongji" data-type="tongji_type">
						<a href="#Statistical">统计管理</a>
					</li>
					<li class="layui-nav-item Resour_header hide" id="bumen" data-type="bumen_type">
						<a href="#Resour">部门管理</a>
					</li>
					<li class="layui-nav-item">
						<a>更多</a>
						<!--<dl class="layui-nav-child" style="color: #000000;">
							下载资源统计表
						</dl>-->
					</li>
				</ul>
				<ul class="layui-nav layui-bg-cyan">
					<li class="layui-nav-item login_emit">
						<a><span class="user_name"></span><span class="user_img"><img src="img/logo.png"/></span></a>
						<dl class="layui-nav-child">
							<dd style="color: black;cursor: pointer;">
								<a onclick="clearCookie()">退出</a>
							</dd>
						</dl>
					</li>
				</ul>
			</div>
		</div>
	</body>
	<script src="js/jquery-2.1.0.js" type="text/javascript" charset="utf-8"></script>
	<script src="layui/layui.js" type="text/javascript" charset="utf-8"></script>
	<script src="js/header.js" type="text/javascript" charset="utf-8"></script>
	<script src='js/sockets.js'></script>
	<script src="js/common.js" type="text/javascript" charset="utf-8"></script>
	<script src="js/header_if.js" type="text/javascript" charset="utf-8"></script>
	<script type="text/javascript">
		layui.use(['element', 'layer', ], function() {
			var layer = layui.layer;
			var element = layui.element;
			var socket = io('http://ts.qdtz999.cn:2120');
			var role_id = getCookie("role_id");
			socket.on('connect', function() {
				socket.emit('login', role_id);
			});
			socket.on('new_msg', function(msg) {
				console.log(msg);
				function isJSON_test(str) {
					if(typeof str == 'string') {
						try {
							var obj = JSON.parse(str);
//							console.log('转换成功：' + obj);
							return true;
						} catch(e) {
//							console.log('error：' + str + '!!!' + e);
							return false;
						}
					}
//					console.log('It is not a string!')
				}
				var msg_type = isJSON_test(msg)
				if(msg_type == true) {
					var msg_json = JSON.parse(msg);
					layer.open({
						type: 1,
						area: '210px',
						title: '您有新消息哦<i class="layui-icon layui-icon-face-smile" style="font-size: 20px; color:red;margin-left:5%;"></i>',
						offset: 'rt',
						shade: 0,
						anim: 6,
						content: '<div class="click_href">回访时间到期，请点击查看··</div>',
						btn: '确定',
						btn1: function(index, curr) {
							$('.MyUser_header').trigger('click');
							localStorage.setItem("picTabNum", '7'); //放入session
							localStorage.setItem("picTabNums", '7'); //放入session
							localStorage.setItem("msg_type", msg_json); //放入session
							$('.MyUser_header').addClass('layui-this').siblings().removeClass('layui-this');
						}
					})
					$('.click_href').parents('.layui-layer').addClass('active');
				} else {
					if(msg == "留言") {
						layer.open({
							type: 1,
							area: '210px',
							title: '您有新消息哦<i class="layui-icon layui-icon-face-smile" style="font-size: 20px; color:red;margin-left:5%;"></i>',
							offset: 'lb',
							shade: 0,
							anim: 6,
							content: '<div>' + msg + '</div>',
							btn: '确定',
							btn1: function(index, curr) {
								$('.index_header').trigger('click');
								$('.index_header').addClass('layui-this').siblings().removeClass('layui-this');
							}
						})
					} else {
						layer.open({
							type: 1,
							area: '210px',
							title: '您有新消息哦<i class="layui-icon layui-icon-face-smile" style="font-size: 20px; color:red;margin-left:5%;"></i>',
							offset: 'rb',
							shade: 0,
							anim: 6,
							content: '<div id="ceshde">' + msg + '</div>',
							btn: '确定',
							btn1: function(index, curr) {
								$('.index_header').trigger('click');
								$('.index_header').addClass('layui-this').siblings().removeClass('layui-this');
							}
						})
					}
				}
			});
			socket.on('update_online_count', function(online_stat) {
//				console.log(online_stat);
				$('#online_box').html(online_stat);
			});
		});
	</script>
	<script type="text/javascript">
		$(".layui-tab-title li").click(function() {
			var picTabNum = $(this).index();
			sessionStorage.setItem("picTabNum", picTabNum);
		});
		$(function() {
			var getPicTabNum = sessionStorage.getItem("picTabNum");
			$(".layui-tab-title li").eq(getPicTabNum).addClass("layui-this").siblings().removeClass("layui-this");
		})
	</script>
	

</html>